package everyday;

import org.junit.jupiter.api.Test;
import tool.s;

public class T2373 {
    public int[][] largestLocal(int[][] grid) {
        int len = grid.length;
        int[][] ints = new int[len][len - 2];
        int[][] res = new int[len - 2][len - 2];
        for (int i = 0; i < len; i++) {
            int max = Math.max(grid[i][0], grid[i][1]);
            int tmp;
            for (int j = 2; j < len; j++) {
                tmp = Math.max(grid[i][j - 1], grid[i][j]);
                ints[i][j - 2] = Math.max(max, tmp);
                max = tmp;
            }
        }
        s.print2(ints);

        for (int i = 0; i <len-2; i++) {
            s.print2(res);
            int max = Math.max(ints[0][i], ints[1][i]);
            int tmp;
            for (int j = 2; j < len; j++) {
                tmp = Math.max(ints[j-1][i], ints[j][i]);
                res[j-2][i] = Math.max(max, tmp);
                max = tmp;
            }
        }
        return res;
    }
    @Test
    public void test() {
        int [][]ints={{1,1,1,1,1},{1,1,1,1,1},{1,1,2,1,1},{1,1,1,1,1},{1,1,1,1,1}};
        s.print2(largestLocal(ints));

    }
}
